package test;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.TypeVariable;
import java.util.ArrayList;

import points2D.Point;

import shape2D.Carre;


public class LookingClass {
	
	public static void main(String[] args) throws Exception{
	
	
		Class<?> client=Class.forName("shape2D.Carre" ); 
		Class<?> tableau[]=client.getClasses();
		int i=0; 
		for(Class<?> c:tableau){
			System.out.println(i+" "+c);
			i++; 
	
		System.out.println("fini pour les classes incluses");
		}
		
		Class<?> laSuperClasse=client.getSuperclass(); 
		System.out.println("Super classe : "+laSuperClasse); 
		Class<?> lesInterfaces[]=client.getInterfaces();
		i=0;
		System.out.println("Interfaces implémentées :"); 
		for(Class<?> in:lesInterfaces)
			System.out.println((i++)+" "+in); 
		
		Method lesMethodes[]=client.getMethods(); 
		i=0; 
		System.out.println("Les methodes "); 
		for(Method m:lesMethodes)
			System.out.println((i++)+" "+m);
		
		
		Carre  caro=(Carre)client.newInstance(); 
		System.out.println("\n ***"+caro); 
		
		
		Constructor<?> lesConstructeurs[]=client.getConstructors(); 
		for(Constructor<?> co:lesConstructeurs){
			System.out.println(co);
			Class<?> lesParams[]=co.getParameterTypes(); 
			for(Class<?> tp:lesParams)
				System.out.println("\t"+tp);
		}
		
		ArrayList<Point> bidon=new ArrayList<Point>();
		Constructor<Carre> myco=(Constructor<Carre>)client.getConstructor(ArrayList.class,String.class); 
		Carre cari=myco.newInstance(bidon,"nouveau message");
		System.out.println("-->"+cari);
		
		
		Field[] lesChamps=client.getFields(); 
		for(Field f:lesChamps)
			System.out.println(f.getName()+":"+f.getType()); 
		
	}
	

}
